package com.attedu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

/**
 * @author tune_the last
 * @date 2025/11/3 - 17:30
 */
public class Demo02JDBC {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8", "root", "ASD13579asd");
        String sql = "INSERT INTO user(username, password, nickname, age) values(?,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, "乔碧萝");
        preparedStatement.setString(2, "aaaqbl");
        preparedStatement.setString(3, "qbl");
        preparedStatement.setInt(4, 58);
        preparedStatement.executeUpdate();
        connection.close();
    }
}
